package chapter06.属性和方法整体练习.案例1.案例2;

/**
 * ClassName: CircleTest
 * Package: 案例2
 * Description:
 *
 * @Author fjorid
 * @Create 2025/1/9 20:54
 * @Version 1.0
 */
// 测试类CircleTest
// 定义Circle类
class Circle {
    // 属性：半径
    double radius;

    // 构造方法，用于初始化圆的半径
    Circle(double r) {
        radius = r;
    }

    // 方法：计算圆的面积
    double area() {
        return Math.PI * radius * radius;
    }
}


public class CircleTest {
    public static void main(String[] args) {

        Circle myCircle = new Circle(5);


        System.out.println("The area of the circle is: " + myCircle.area());
    }
}